package org.graduates.webapp.actions.course.json;

import org.apache.commons.lang3.StringUtils;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.graduates.webapp.actions.BaseAction;
import org.projects.graduates.domain.TimeTable;

@Action(results = { @Result(name = "success", type = "json"), @Result(name = "input", type = "json") })
public class CheckBeforeHomeworkAction extends BaseAction {

	private static final long serialVersionUID = 153625574176648942L;

	private long tid = 0L;

	private boolean access = false;

	public String execute() {

		if (0L == tid) {
			return SUCCESS;
		}

		TimeTable tt = TimeTable.get(TimeTable.class, tid);
		if (null == tt) {
			return SUCCESS;
		}
		if (null == tt.getContent() || StringUtils.isEmpty(tt.getContent().getTxt())) {
			return SUCCESS;
		}
		access = true;
		return SUCCESS;
	}

	public long getTid() {
		return tid;
	}

	public void setTid(long tid) {
		this.tid = tid;
	}

	public boolean isAccess() {
		return access;
	}

}
